var o = {
  f: function () {
    console.log("f", this);
  },
  b: 4,
  a: {
    af: function () {
      console.log("af", this);
    },
    b() {
      console.log("b", this);
    },
    c: 5
  }
};
var str = JSON.stringify(
  o,
  function (k, v) {
    // console.log("[stringify]", k, v);
    return typeof v === "function" ? v.toString() : v;
  },
  2
);
console.log(o.f(), o.a.af(), str);
///////
var o1 = JSON.parse(str, function (k, v) {
  console.log("[parse]", k, v);

  var fn = typeof v === "string" ? new Function(`return ${v}`)() : v;
  return typeof fn === "function" ? fn : v;
});

console.log("=====", o1);
console.log(o1.f(), o1.a.af());
